<template>
  <div class="header clearFloat">
        <div  class="headerBox" @click="collBtn(!isCollapse)" >
        <i :class="isCollapse==false?'el-icon-s-fold':'el-icon-s-unfold'"></i>
      </div>
      <div class="headerCrumb">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item @click.native="indexBtn" 
          :to="this.$route.name=='home'?false:{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item v-if="this.$route.meta.title!='首页'">
            {{this.$route.meta.title}}
          </el-breadcrumb-item>
          
       </el-breadcrumb>
      </div>
      <div class="headerAvatar">
       <el-dropdown trigger="click">
        <span class="el-dropdown-link">
          <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></el-avatar>
        </span>
      <el-dropdown-menu slot="dropdown">
         <el-dropdown-item>首页</el-dropdown-item>
         <el-dropdown-item>项目地址</el-dropdown-item>
         <el-dropdown-item>修改密码</el-dropdown-item>
         <el-dropdown-item @click.native="removeBtn">退出登录</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
   </div>

  </div>
</template>

<script>
import Cookies from "js-cookie";
export default {
    name:"Header",
    data( ) {
        return {
            isCollapse: this.$store.state.isCollapseStore,
        }
      },
      methods :{
        //展开收起
        collBtn(user){
          this.isCollapse=user;
          // this.$bus.$emit("isCollapseFun",this.isCollapse)
          this.$store.commit("func1",this.isCollapse);
        },
        //退出登录
        removeBtn(){
          this.$message({
                message: "退出登录",
                type: 'success'
              });
          Cookies.remove("token");
          this.$router.push("/login");
        },
        //回到首页
        indexBtn(){
          this.$store.commit("func2","home");
        }
      }
  }
</script>

<style scoped>
.header{
    width: 100%;
    height: 10vh;
    box-shadow: 0 1px 4px rgb(0 21 41 / 8%);
}
.headerBox{
  width: 10vh;
  height: 10vh;
  display: inline-block;
  font-size: 26px;
  line-height: 10vh;
  text-align: center;
  float: left;
}
.headerAvatar{
  float: right;
  width: 10vh;
  height: 10vh;
  display: inline-block;
  margin-right: 4vh;
}
.el-avatar{
  width: 8vh;
  height: 8vh;
  display: inline-block;
  margin: 1vh;
}
.headerCrumb{
  float: left;
  display: inline-block;
  line-height: 10vh;
}
.el-breadcrumb{
  line-height: 10vh;
}
</style>